package com.token.test.get;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.token.sysflow.action.GetPathApproverAction;
import com.token.sysflow.action.LoadFlowStepAction;
import com.token.sysflow.action.SubmitFlowAction;
import com.token.test.util.FuncUtilTest;
import com.token.test.util.IntegrateSqlTest;
import org.apache.commons.io.FileUtils;

import java.io.File;

/**
 * 非第一次的提交
 * @author chenjianxiong 2020/6/3
 */
public class GetSubmitStepTest2 {

    public static void main(String[] args) {
        FuncUtilTest f;
        IntegrateSqlTest iSql;
        try {
            SubmitFlowAction submitFlowAction = new SubmitFlowAction();
            String path = submitFlowAction.getClass().getClassLoader().getResource("json/SubmitFlowAction.json").getPath();
            String json = FileUtils.readFileToString(new File(path), "UTF-8");
            JSONObject jsonObject = JSON.parseObject(json);

            JSONObject tmp;
            JSONObject returnJson;
            String keyUnid;
            iSql = new IntegrateSqlTest();
            iSql.initCon();

            f = new FuncUtilTest(jsonObject.getJSONObject("editLoad"));
            System.out.println("====1.起草进入====");
            new LoadFlowStepAction().executeAction(f, iSql);
            keyUnid = f.getUrlQueryString("keyUnid");
            returnJson = f.getJsonData();
            if (!f.testOk(returnJson)) {
                return;
            }
            System.out.println(" ");
            //==================================================
            //测试开始环节提交后。。。
            tmp = jsonObject.getJSONObject("getPath_02");
            tmp.put("keyUnid",keyUnid);
            f = new FuncUtilTest(tmp);
            System.out.println("====2.提交框====");
            new GetPathApproverAction().executeAction(f, iSql);
            returnJson = f.getJsonData();
            JSONArray data = returnJson.getJSONArray("data");
            System.out.println("data.size() = " + data.size());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
